#include <stdio.h>
#include <vector>
#define bigger(a,b) (a)>(b)?(a):(b)
using namespace std;
int n;

int shu[102][102];

int ans[102];

int main()
{
	int i, j, a;
 	
    while (scanf("%d", &n)!=EOF)
    {
        for (i=1; i<=n; ++i)
        	for (j=1; j<=i; ++j)
       		    scanf("%d", &shu[i][j]);
     
        for (i=1; i<=n; ++i)
        	ans[i] = shu[n][i];

       	for (i=n-1; i>=1; --i)
       		for (j=1; j<=i; ++j)
       			ans[j] = shu[i][j] + (bigger(ans[j], ans[j+1]));
    	printf("%d\n", ans[1]);
   	}   			
           
        
    
}   
 
